package com.neusoft.mapper;

import com.neusoft.domain.DeliveryAddress;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeliveryAddressDao {

    @Select("select * from deliveryaddress where userId = #{userId} order by daId")
    List<DeliveryAddress> listDeliveryAddressByUserId(String userId);

    @Insert("insert into deliveryAddress(contactName,contactSex,contactTel,address,userId) values(#{contactName},#{contactSex},#{contactTel},#{address},#{userId})")
    Integer saveDeliveryAddress(DeliveryAddress deliveryAddress);

    @Delete("delete from deliveryAddress where daId=#{daId}")
    Integer removeDeliveryAddress(Integer daId);

    @Select("select * from deliveryaddress where daId = #{daId}")
    DeliveryAddress getDeliveryAddressById(Integer daId);

    @Update("update deliveryAddress set contactName=#{contactName},contactSex=#{contactSex},contactTel=#{contactTel},address=#{address},userId=#{userId} where daId=#{daId}")
    Integer updateDeliveryAddress(DeliveryAddress deliveryAddress);
}
